package cn.tl.hrm.service.impl;

import cn.tl.hrm.domain.LoginUser;
import cn.tl.hrm.dto.LoginUserDto;
import cn.tl.hrm.mapper.LoginUserMapper;
import cn.tl.hrm.service.ILoginUserService;
import cn.tl.hrm.util.AjaxResult;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yaosang
 * @since 2022-04-04
 */
@Service
public class LoginUserServiceImpl extends ServiceImpl<LoginUserMapper, LoginUser> implements ILoginUserService {

    @Autowired
    private LoginUserMapper loginUserMapper;
    @Override
    public AjaxResult addLoginUserDto(LoginUserDto loginUserDto) {
        //保存用户信息
        LoginUser loginUser = loginUserDto.getLoginUser();
        loginUserMapper.insert(loginUser);
        //保存用户和套餐中间表信息
        loginUserMapper.saveLoginUserMeals(loginUser.getId(),loginUserDto.getMealId());
        return AjaxResult.me().setResultObj(loginUser.getId());
    }
}
